﻿using B.S.BaseData.ErrorCode;
using B.S.BaseData.Manage.Api.With.Apliaction.Command.InventoryCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BaseData.Manage.Api.With.Controllers
{
    /// <summary>
    /// 写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class StoreController : ControllerBase
    {
        private readonly IMediator mediator;

        public StoreController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 新增加入库
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiReqult<object>> StoreAdd(StoreAddCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 执行入库逻辑删除操作
        /// </summary>
        /// <param name="request">包含要删除记录ID的请求</param>
        /// <returns>包含操作结果的ApiReqult对象</returns>
        [HttpPost]
        public async Task<ApiReqult<object>> StoreDelete([FromQuery]StoreDeleteCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 执行入库修改操作
        /// </summary>
        /// <param name="request">包含要修改操</param>
        /// <returns>包含操作结果的ApiReqult对象</returns>
        [HttpPost]
        public async Task<ApiReqult<object>> StoreUpdate(StoreUpdateCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
